package com.mou.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.mou.dto.UserDTO;
import com.mou.dto.UserPageQueryDTO;
import com.mou.entity.OnlineUser;
import com.mou.entity.User;
import com.mou.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper extends BaseMapper<User> {
    @Select("select * from online_user where user_id = #{id}")
    OnlineUser getOnlineUserById(Integer id);


    @Update("update user set role_id = 0 where role_id = #{id}")
    void updateByRoleId(Integer id);

    @Select("select * from user where username=#{username} or id = #{id} or email=#{username}")
    User getByUser(User u);

    Page<UserVO> pageQuery(UserPageQueryDTO userPageQueryDTO);

    @Update("update user set password = #{password} where username = #{username} and email = #{email}")
    void forgotPassword(User user);

    @Select("select count(*) from user where username = #{username} or email = #{email}")
    Integer uniqueUser(User user);


}
